<script src="../../routers/main.js"></script>
<script src="../../models/blog.js"></script>
<script src="../../routers/admin.js"></script>
<script src="../../routers/api.js"></script>{% extends 'layout.html'%}
{% block title%}添加博客{%endblock%}
{% block body%}
{% block scripts%}
<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js">
</script>
<script>
    $(function(){
        let $name =$("#name");
        let $url =$("#url");
        let $id =$("#id");
        $("#submit").click(function(){
            $.post("/admin/links/add",{
                    name:$name.val(),
                    url:$url.val(),
                    id:$id.val(),
                },
                function(result){
                    if(result.msg=="提交成功"){
                        alert("提交成功");
                    }else if(result.msg="修改成功") {
                        alert('修改成功');
                    }
                    window.location.href='/admin/links?page=1'
                });
        });
    });
</script>
{%endblock%}
<form>
    <div class="form-group" >
        <h4>新建友情链接</small></h4>
        <h5>链接名称</h5>
        <input id="name" type="text" class="form-control" placeholder="名称" value={{link.name}} >
        <h5>链接地址</h5>
        <input id="url" type="text" class="form-control" placeholder="url" value={{link.url}}>
    </div>
   <input id="id" hidden value={{link._id.toString()}} >

</form>

<button id="submit" type="button" class="btn btn-primary btn-lg btn-block">提交</button>
{% endblock%}